//
//  VerticallyCenteredButtonCell.m
//  AnimatedFlashcards
//
//  Created by Timothy Costa on 11/4/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "VerticallyCenteredButtonCell.h"

@implementation VerticallyCenteredButtonCell

-(NSRect)drawTitle:(NSAttributedString *)title withFrame:(NSRect)frame inView:(NSView *)controlView
{
	NSSize size = NSMakeSize(frame.size.width,frame.origin.y*2); // original drawing is for one line in the center
	NSRect titleRect = [title boundingRectWithSize:size
										   options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin];

	titleRect.origin.x = 5 + frame.size.width/2 - titleRect.size.width/2;
	titleRect.origin.y = (frame.origin.y + frame.size.height/2) - titleRect.size.height/2; // this should stay on the original line if only 1 line long...
	[title drawInRect:titleRect];
	return titleRect;
}
@end